#!/usr/bin/env python
# -*- coding: UTF-8 -*-
'''
@Project ：图灵学习 
@File    ：11.上下文管理器协议.py
@IDE     ：PyCharm 
@Author  ：ChenLiGao
@Date    ：2024-10-30 10:11
'''

class Test:
    def __enter__(self):
        print(1)
        return self

    def __exit__(self, exc_type, exc_val, exc_tb):
        print(2)

    def run(self):
        print("run......")

with Test() as t:
    t.run()